import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class GridMoreDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<Container> _buildTitleList(int count) {
      return List.generate(
          count,
          (index) => Container(
                child: Image.asset(
                  'images/card0${index + 1}.png',
                  fit: BoxFit.cover,
                ),
              ));
    }

    Widget _buildGrid() => GridView.extent(
          //item最大宽度
          maxCrossAxisExtent: 150.0,
          //内边距
          padding: EdgeInsets.all(4.0),
          //主轴item间距
          mainAxisSpacing: 15.0,
          //次轴item间隙
          crossAxisSpacing: 15.0,
          children: _buildTitleList(9),
        );
    return Scaffold(
      appBar: AppBar(
        title: Text('GridView示例'),
        centerTitle: true,
      ),
      body: Center(
        child: _buildGrid(),
      ),
    );
  }
}
